home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
EnigmA Amiga Run 1995 November
/
EnigmA AMIGA RUN 02 (1995)(G.R. Edizioni)(IT)[!][issue 1995-11][Skylink CD].iso
/
earcd
/
util
/
misc
/
verctrl_1.16.lha
/
VerCtrl.rexx
< prev
Wrap
OS/2 REXX Batch file
|
1995-08-05
|
6KB
|
201 lines
/*\
*
* $VER: VerCtrl.rexx 1.16 (5.8.95)
*
\*/
VersMsg = "VerCtrl.rexx 1.16 (5.8.95)"
Author = "Dave Freeman"
Contact = "dfreeman@icecave.apana.org.au"
OPTIONS RESULTS
SIGNAL ON ERROR
SIGNAL ON BREAK_C
SIGNAL ON SYNTAX
LibList = 'rexxsupport.library rexxdossupport.library'
DO Count = 1 TO WORDS(LibList)
IF ~SHOW('l',WORD(LibList,Count)) THEN DO
IF ~ADDLIB(WORD(LibList,Count),0,-30) THEN DO
CALL GSay("Error: "WORD(LibList,Count)"not available","Damn!")
EXIT 5
END
END
END
/* ----------------------------------------------------------------------------------------------- */
/* Handle Args for the Program */
/* ----------------------------------------------------------------------------------------------- */
PARSE ARG ArgString
Template = "RexxScript/A,DirPath/A,New/S"
IF ~ReadArgs(ArgString,Template) THEN DO
ErrorMsg = "Error: Incorrect/Incomplete Call to Script*NTemplate: "Template
CALL GSay(ErrorMsg,"OK")
END
IF LEFT(DirPath,8) = 'Ram Disk' THEN DO
PARSE UPPER VAR DirPath ':' SubDirs
DirPath = 'RAM:'SubDirs
END
IF INDEX(DirPath,':') = 0 THEN DirPath = DirPath':'
ELSE IF (RIGHT(DirPath,1) ~= '/') & (RIGHT(DirPath,1) ~= ':') THEN DirPath = DirPath'/'
Work_Dir = DirPath
VStr = 0
/* ----------------------------------------------------------------------------------------------- */
StoreDir = PRAGMA('D') /* Remember Current Dir and go back there at the end */
CALL PRAGMA('D',Work_Dir)
/* ----------------------------------------------------------------------------------------------- */
extpos = LASTPOS('.',RexxScript)
IF extpos = 0 THEN DO
IF New = 1 THEN DO
RexxPath = Work_Dir||RexxScript
END
ELSE DO
RexxPath = Work_Dir
END
RexxScript = RexxScript'.rexx'
END
ELSE DO
IF New = 1 THEN DO
RexxPath = Work_Dir||LEFT(RexxScript,extpos - 1)
END
ELSE DO
RexxPath = Work_Dir
END
END
IF New = 1 THEN DO
CALL MAKEDIR(RexxPath)
RexxPath = RexxPath'/'
extpos = LASTPOS('.',RexxScript)
scriptext = RIGHT(RexxScript,LENGTH(RexxScript) - extpos + 1)
IF EXISTS('REXX:RexxProg'scriptext) THEN DO
DefScript = 'REXX:RexxProg'scriptext
END
ELSE DO
DefScript = 'REXX:RexxProg.rexx'
END
CALL OPEN(WorkIn,DefScript,READ)
CALL OPEN(WorkOut,RexxPath||RexxScript,WRITE)
DO FOREVER
LineIn = READLN(WorkIn)
IF EOF(WorkIn) THEN LEAVE
IF INDEX(LineIn,' * $VER:') = 1 THEN DO
LineIn = VerProc(LineIn)
END
IF INDEX(LineIn,'VersMsg = ') = 1 THEN DO
LineIn = 'VersMsg = 'VStr
END
CALL WRITELN(WorkOut,LineIn)
END
CALL CLOSE(WorkIn)
CALL CLOSE(WorkOut)
CALL SetVar(RexxDev.File,RexxPath||RexxScript,"Global")
END
ELSE DO
CALL OPEN(WorkIn,RexxPath||RexxScript,READ)
CALL OPEN(WorkOut,RexxPath||RexxScript'.temp',WRITE)
DO FOREVER
LineIn = READLN(WorkIn)
IF EOF(WorkIn) THEN LEAVE
IF INDEX(LineIn,' * $VER:') = 1 THEN DO
LineIn = VerProc(LineIn)
END
IF INDEX(LineIn,'VersMsg = ') = 1 THEN DO
LineIn = 'VersMsg = 'VStr
END
CALL WRITELN(WorkOut,LineIn)
END
CALL CLOSE(WorkIn)
CALL CLOSE(WorkOut)
CALL PRAGMA('D',RexxPath)
CALL DELETE(RexxScript)
CALL RENAME(RexxScript'.temp',RexxScript)
END
/* ----------------------------------------------------------------------------------------------- */
CALL PRAGMA('D',StoreDir) /* Change to LogPath Dir for Stat Processing */
/* ----------------------------------------------------------------------------------------------- */
EXIT(0)
/* ----------------------------------------------------------------------------------------------- */
/* CALL Routines start here */
/* ----------------------------------------------------------------------------------------------- */
VerProc: PROCEDURE EXPOSE RexxScript VStr
WorkLine = ARG(1)
IF WORDS(WorkLine) > 2 THEN DO
PARSE VAR WorkLine junk junk progname verstr datestr
verstr = VerInc(verstr)
datestr = DateInc()
WorkLine = " * $VER: "progname" "verstr" "datestr
IF VStr = 0 THEN VStr = '"'progname' 'verstr' 'datestr'"'
END
ELSE DO
PARSE VAR WorkLine comnt verstr
verstr = 1.0
datestr = DateInc()
WorkLine = " * $VER: "RexxScript" "verstr" "datestr
IF VStr = 0 THEN VStr = '"'RexxScript' 'verstr' 'datestr'"'
END
RETURN(WorkLine)
VerInc: PROCEDURE
VerStr = TRANSLATE(ARG(1),' ','.')
VerStr = WORD(VerStr,1)'.'WORD(VerStr,2) + 1
RETURN(VerStr)
DateInc: PROCEDURE
DateStr = TRANSLATE(DATE('e'),' ','/')
DateDay = STRIP(STRIP(WORD(DateStr,1)),'L','0')
DateMnt = STRIP(STRIP(WORD(DateStr,2)),'L','0')
DateYer = STRIP(WORD(DateStr,3))
DateStr = '('DateDay'.'DateMnt'.'DateYer')'
RETURN(DateStr)
GSay: PROCEDURE EXPOSE VersMsg /* GSay("Message Text","Option1","Option2","OptionN") */
GChoice. = 0 ; GChoiceStr = ' "'
ArgCount = ARG()
GTitle = VersMsg
GMessage = ARG(1)
DO Count = 2 TO ArgCount
GChoiceStr = GChoiceStr||ARG(Count)'" "'
END
GChoiceStr = DELSTR(GChoiceStr,LENGTH(GChoiceStr) - 1)
ADDRESS COMMAND 'RequestChoice "'GTitle'" "'GMessage'"'||GChoiceStr' >T:ChoiceRet'
CALL OPEN(ChoiceIn,'T:ChoiceRet',READ)
ChoiceRet = READLN(ChoiceIn)
IF ChoiceRet = 0 THEN ChoiceRet = ArgCount - 1
CALL CLOSE(ChoiceIn)
CALL DELETE('T:ChoiceRet')
RETURN(ChoiceRet)
/* ----------------------------------------------------------------------------------------------- */
/* Error Handling Routines start here */
/* ----------------------------------------------------------------------------------------------- */
BREAK_C:
Err1 = 'Break-C Signal Detected'
Err2 = 'Execution Ceased at line - 'SIGL
Err3 = 'Source Line: 'SourceLine(SIGL)
ErrText = Err1'*n'Err2'*n'Err3
CALL GSay(ErrText,"OK")
EXIT 10
RETURN
ERROR:
SYNTAX:
Err1 = 'Trapped Error: 'ErrorText(rc)
Err2 = 'Line 'SIGL':'SourceLine(SIGL)
ErrText = Err1'*n'Err2
CALL GSay(ErrText,"Damn!")
EXIT 20
RETURN